<?php

/**
 * WeEngine Api System
 *
 * (c) We7Team 2019 <https://www.w7.cc>
 *
 * This is not a free software
 * Using it under the license terms
 * visited https://www.w7.cc for more details
 */

namespace W7\Sdk\VSCode\Tests;

use W7\Sdk\VSCode\Traits\StorageTrait;

/**
 * fs read file
 */
class TestFileRead extends TestCase {
	use StorageTrait;

	/**
	 * @var string
	 */
	private $content = 'hello123456';

	private $txtFile = '/api/test.txt';
	/**
	 * @var string
	 */
	private $route = '';

	protected function setUp(): void {
		parent::setUp(); // TODO: Change the autogenerated stub
		$this->route = route('vs.code.read.file', ['uri' => $this->txtFile]);
	}

	/**
	 * test read file
	 */
	public function testFileRead() {
		$this->storageDeleteFile($this->txtFile);

		$this->storagePutContent($this->txtFile, $this->content);
		$this->assertTrue($this->storageIsExists($this->txtFile));

		$response = $this->getJson($this->route)->assertOk();
		$this->assertEquals($this->content, $response->json('content', 'a'));
	}
}
